lisp codeEn 2017-02-22 09:31:04
We are going to using cxml library.

(defun generate-sitemap (urls)
  "Creates the sitemap file"
  (with-open-file (file "/tmp/sitemap.xml"
            :direction :output
            :element-type :default
            :if-exists  :supersede)
    (cxml:with-xml-output (cxml:make-octet-stream-sink file :indentation 1 :canonical nil)
      (cxml:with-element "urlset"
    (cxml:attribute "xmlns" "http://www.sitemaps.org/schemas/sitemap/0.9")
    ;; create the tags
    (dolist (item urls)
     (cxml:with-element "url"
       (cxml:with-element "loc"
         (cxml:text item))
       (cxml:with-element "changefreq"
         (cxml:text "daily"))))))))
 
#lisp

 
También te puede interesar
lisp codeEn 2022-07-13 13:12:00